package com.onenine.app.utils;

import android.content.res.ColorStateList;
import android.support.v4.app.ActivityCompat;

import com.onenine.chat.rongcloud.RcUser;
import com.onenine.common.util.ApUtils;
import com.onenine.ddrawable.DynamicResLoader;
import com.onenine.ddrawable.SuffixItem;
import com.onenine.ddrawable.SuffixRegister;

/**
 * 男女角色资源加载
 */
public class RoleResLoader {

    /**
     * 动态资源常量定义
     */
    public interface DynamicResName {
        //主题
        String THEME_COLOR = "theme_color";
        //主题1
        String THEME_COLOR1 = "theme_color1";
        //Main Tab字体颜色
        String MAIN_TAB_TEXT_COLOR = "selector_main_tab_text_color";
        //Main游戏tab
        String MAIN_TAB_GAME = "selector_tab_game_icon";
        //Main社区tab
        String MAIN_TAB_COMMUNITY = "selector_tab_community_icon";
        //Main发现tab
        String MAIN_TAB_FIND = "selector_tab_find_icon";
        //Main消息tab
        String MAIN_TAB_MESSAGE = "selector_tab_msg_icon";
        //Main游戏tab
        String MAIN_TAB_MINE = "selector_tab_mine_icon";
        //圆点提醒
        String CIRCLE_POINT_BUBBLE = "shape_bubble_point_bg";
        //标签背景
        String SELECTOR_LABEL_ITEM_BG = "selector_label_item_bg";
        //标签文本
        String SELECTOR_LABEL_ITEM_TEXT_BG = "selector_label_item_text_bg";
        //按钮圆角渐变背景
        String THEME_GRADIENT_CORNER_BG = "shape_btn_gradient_corner_bg";
        //主题渐变背景
        String THEME_GRADIENT_BG = "shape_btn_gradient_bg";
        //圆角边框白底
        String THEME_STROKE_WHITE_CORNER = "shape_btn_stroke_corner_white_bg";
        //个人中心的地址
        String MINE_ADDR_ICON = "ic_mine_addr";
        //多选框样式
        String CHECKBOX_STYLE = "ic_checked";
        //社区的性别
        String COMMUNITY_SEX_ICON = "ic_community_sex";
        //帖子内容背景
        String POST_ITEM_BG = "shape_post_content_item_bg";
        //游戏项限制性别
        String IC_GAME_ITEM_SEX = "ic_game_item_sex";
        //创建弹幕按钮
        String BTN_BARRAGE_CREATE = "ic_barrage_create";
        //弹幕白色性别
        String IC_SEX_WHITE = "ic_sex_white";
        //个人中心关心
        String SELECTOR_UD_ATTENTION_BG = "selector_ud_attention_status";
        //完善资料弹窗图标
        String INFO_IMCOMPLETE_LOGO = "ic_info_imcomplete_icon";
        //充值顶背景
        String IC_RECHARGE_TOP_BG = "ic_recharge_top_bg";
        //充值项边框
        String IC_RECHARGE_ITEM_BORDER = "ic_recharge_item_border";
        //水平进度条样式
        String HORIZONTAL_PROGRESS_BAR_BG = "shape_progress_bar_drawable_bg";
        //我的年龄和性别背景
        String SHAPE_MINE_SEX_AGE_BG = "shape_mine_age_sex_bg";
        //我的-动态
        String IC_M_DYNAMIC = "ic_m_dynamic";
        //语音条左背景
        String IC_VOICE_LEFT_BAR_BG = "ic_voice_bar_left_bg";
        //语音条右背景
        String IC_VOICE_RIGHT_BAR_BG = "ic_voice_bar_right_bg";
        //游戏选项按钮背景
        String SELECTOR_GAME_BUTTON_BG = "selector_game_btn_bg";
        //语音滑条背景
        String SHAPE_GAME_SEEKBAR_BG = "shape_seek_bar_drawable_bg";
        //社区全部图片
        String IC_COMMUNITY_TOP_ALL_BG = "ic_community_top_all_bg";
        //游戏钻石数量背景
        String IC_GAME_AMOUNT_COUNT_BG = "shape_game_item_amount_bg";
    }

    /**
     * 注册角色资源类型
     */
    public static void registerRoleSuffixType() {
        SuffixRegister.getInstance().registerSuffixType(new SuffixItem(DataType.SEX_MALE, "male"))
                .registerSuffixType(new SuffixItem(DataType.SEX_FEMALE, "female"));
    }

    /**
     * 获取角色Drawable资源id
     *
     * @param resName
     * @return
     */
    public static int getRoleDrawableResourceId(String resName) {
        int sex = RcUser.getInstance().getSex();
        return DynamicResLoader.getDrawableIdByIdentifier(ApUtils.getApp()
                , sex > 0 ? sex : DataType.SEX_MALE, resName);
    }

    /**
     * 获取角色Drawable资源id
     *
     * @param resName
     * @return
     */
    public static int getRoleDrawableResourceId(String resName, int sex) {
        return DynamicResLoader.getDrawableIdByIdentifier(ApUtils.getApp()
                , sex > 0 ? sex : DataType.SEX_MALE, resName);
    }

    /**
     * 获取角色Color资源id
     *
     * @param resName
     * @return
     */
    public static int getRoleColorResourceId(String resName) {
        int sex = RcUser.getInstance().getSex();
        return ActivityCompat.getColor(ApUtils.getApp(), DynamicResLoader.getColorIdByIdentifier(ApUtils.getApp()
                , sex > 0 ? sex : DataType.SEX_MALE, resName));
    }

    /**
     * 获取角色Color资源id
     *
     * @param resName
     * @return
     */
    public static int getRoleColorResourceId(String resName, int sex) {
        return ActivityCompat.getColor(ApUtils.getApp(), DynamicResLoader.getColorIdByIdentifier(ApUtils.getApp()
                , sex > 0 ? sex : DataType.SEX_MALE, resName));
    }

    /**
     * 获取角色ColorStateList资源
     *
     * @param resName
     * @return
     */
    public static ColorStateList getRoleColorStateList(String resName) {
        int sex = RcUser.getInstance().getSex();
        return ActivityCompat.getColorStateList(ApUtils.getApp(), DynamicResLoader.getDrawableIdByIdentifier(ApUtils.getApp()
                , sex > 0 ? sex : DataType.SEX_MALE, resName));
    }

    /**
     * 获取角色ColorStateList资源
     *
     * @param resName
     * @param sex
     * @return
     */
    public static ColorStateList getRoleColorStateList(String resName, int sex) {
        return ActivityCompat.getColorStateList(ApUtils.getApp(), DynamicResLoader.getDrawableIdByIdentifier(ApUtils.getApp()
                , sex, resName));
    }

}
